package com.kcwl.carrier.domain.service;

import com.kcwl.carrier.domain.entity.CancelApproveRemarkCommand;
import com.kcwl.carrier.domain.entity.CancelApproveRemarkInfo;
import com.kcwl.carrier.domain.repository.ICancelApproveRemarkRepository;
import com.kcwl.carrier.infrastructure.repository.po.CancelApproveRemarkPO;
import com.kcwl.framework.utils.KcBeanConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ckwl
 */
@Slf4j
@Service
public class CancelApproveRemarkDomainService {

    @Resource
    private ICancelApproveRemarkRepository cancelApproveRemarkRepository;


    public CancelApproveRemarkInfo addRemark(CancelApproveRemarkCommand command) {
        CancelApproveRemarkPO po = KcBeanConverter.toBean(command, CancelApproveRemarkPO.class);
        cancelApproveRemarkRepository.save(po);
        return KcBeanConverter.toBean(po, CancelApproveRemarkInfo.class);
    }

    public CancelApproveRemarkInfo getById(Long id) {
        return KcBeanConverter.toBean(cancelApproveRemarkRepository.getById(id), CancelApproveRemarkInfo.class);
    }
}
